import axios from 'axios';
import { loginreq, req } from './axiosFun';

// 登录接口
export const login = (params) => { return axios.get("/api/login/login?&username=" + params.username +"&userpwd="+params.userpwd).then(res => res.data) };
// 获取用户菜单
export const menu = (params) => { return axios.get("/api/menu?&token=" + localStorage.getItem('logintoken')).then(res => res.data) };
// 退出接口
export const loginout = () => { return axios.delete("/api/login?&token=" + localStorage.getItem('logintoken')).then(res => res.data) };


/**
 * 模型tag管理
 **/
// 模型tag管理-获取tag列表
export const ModelTagList = (params) => { return req("get", "http://127.0.0.1:10001/modelTagInfo/list?pageNum="+params.pageNum+"&pageSize="+params.pageSize+"&modelTag="+params.modelTag)};
// 模型tag管理-根据Id获取Tag
export const getTagById = (params) => { return req("get", "http://127.0.0.1:10001/modelTagInfo/detail?id="+params.modelTagId)};
// 模型tag管理-获取tag列表
export const ModelTagAllList = () => { return req("get", "http://127.0.0.1:10001/modelTagInfo/selectAll")};
// 模型tag管理-保存（添加编辑）
export const ModelTagSave = (params) => { return req("post", "http://127.0.0.1:10001/modelTagInfo/saveOrUpdate", params) };
// 模型tag管理-删除tag
export const ModelTagDelete = (params) => { return req("post", "http://127.0.0.1:10001/modelTagInfo/delete", params) };
/**
 * 发票管理
 **/

// // 发票管理-根据Id获取发票
// export const getFapiaoById = (params) => { return req("get", "http://127.0.0.1:10001/modelTagInfo/detail?id="+params.modelTagId)};
// 发票管理-获取发票列表
export const FapiaoAllList = () => { return req("get", "http://127.0.0.1:10001/modelTagInfo/selectAll")};
// 发票管理-获取发票列表
export const FapiaoList = (params) => { return req("get", "http://192.168.2.88:9990/api/bill/selectAll?current="+params.pageNum+"&size="+params.pageSize+"&baoxiaoname="+params.baoxiaoname+"&billnum="+params.billnum)};
// 发票管理-保存（添加编辑）
export const FapiaoSave = (params) => { return req("post", "http://192.168.2.88:9990/api/bill/insert", params) };
export const FapiaoUpdate = (params) => { return req("post", "http://192.168.2.88:9990/api/bill/update", params) };
//
// export const FapiaoList = (params) => { return req("get", "http://127.0.0.1:9990/api/bill/selectAll?current="+params.pageNum+"&size="+params.pageSize+"&baoxiaoname="+params.baoxiaoname+"&billnum="+params.billnum)};
// export const FapiaoSave = (params) => { return req("post", "http://127.0.0.1:9990/api/bill/insert", params) };
//
// export const FapiaoUpdate = (params) => { return req("post", "http://127.0.0.1:9990/api/bill/update", params) };

// export const ipmessageList = (params) => { return req("get", "http://127.0.0.1:9991/api/ipmessage/selectAll?current="+params.pageNum+"&size="+params.pageSize+"&ipname="+params.ipname)};
// export const ippasswordList = (params) => { return req("get", "http://127.0.0.1:9991/api/ippassword/selectOne?hostaddress="+params.ipadress)};
// export const bindIp = (params) => { return req("post", "http://127.0.0.1:9991/api/ippassword/bindIp",params)};
// export const unbindIp = (params) => { return req("post", "http://127.0.0.1:9991/api/ippassword/unbindIp",params)};

export const ipmessageList = (params) => { return req("get", "http://192.168.2.88:9991/api/ipmessage/selectAll?current="+params.pageNum+"&size="+params.pageSize+"&ipname="+params.ipname)};
export const ippasswordList = (params) => { return req("get", "http://192.168.2.88:9991/api/ippassword/selectOne?hostaddress="+params.ipadress)};
export const bindIp = (params) => { return req("post", "http://192.168.2.88:9991/api/ippassword/bindIp",params)};
export const unbindIp = (params) => { return req("post", "http://192.168.2.88:9991/api/ippassword/unbindIp",params)};

export const categoryList = (params) => { return req("get", "/api/wikiCategory/selectAll?current="+params.pageNum+"&size="+params.pageSize)};
export const categorySave = (params) => { return req("post", "/api/wikiCategory/insert",params)};
export const categoryUpdate = (params) => { return req("post", "/api/wikiCategory/update",params)};
export const categoryDelete = (params) => { return req("post", "/api/wikiCategory/delete?id="+params.id)};
export const getAllCategoryList = () => { return req("get", "/api/wikiCategory/getAll")};

export const wikiDocList = (params) => { return req("get", "/api/wikiDoc/selectAll?current="+params.pageNum+"&size="+params.pageSize+"&categoryId="+params.categoryId)};
export const wikiDocSave = (params) => { return req("post", "/api/wikiDoc/insert",params)};
export const wikiDocUpdate = (params) => { return req("post", "/api/wikiDoc/update",params)};
export const wikiDocDelete = (params) => { return req("post", "/api/wikiDoc/delete?id="+params.id)};
export const getAllDocList = () => { return req("get", "/api/wikiDoc/getAll")};
export const extractDoc = (params) => { return req("get", "/api/extract/doc?id="+params.id)};

export const rebotList = (params) => { return req("get", "/api/wikiRebot/selectAll?current="+params.pageNum+"&size="+params.pageSize)};
export const rebotSave = (params) => { return req("post", "/api/wikiRebot/insert",params)};
export const rebotUpdate = (params) => { return req("post", "/api/wikiRebot/update",params)};
export const rebotDeployDetail = (params) => { return req("post", "/api/wikiRebot/deployDetail",params)};
export const rebotApi = (params) => { return req("post", "/api/wikiRebot/rebotApi",params)};

/**
 * 模型管理
 **/
// 根据模型id查询tagId
export const getTagIdByModelId = (id) => { return req("get", "http://127.0.0.1:10001/modelInfo/getTagIdByModelId?id="+id)};
// 模型管理-获取模型列表
export const ModelList = (params) => { return req("get", "http://127.0.0.1:10001/modelInfo/list?pageNum="+params.pageNum+"&pageSize="+params.pageSize+"&modelName="+params.modelName)};
// 模型管理-获取模型列表
export const getModelById = (id) => { return req("get", "http://127.0.0.1:10001/modelInfo/detail?id="+id)};
// 模型管理-获取模型列表
export const ModelAllList = () => { return req("get", "http://127.0.0.1:10001/modelInfo/selectAll")};
// 模型管理-获取模型列表
export const ModelgetByModelTagId = (params) => { return req("get", "http://127.0.0.1:10001/modelInfo/getByModelTagId?modelTagId="+params)};
// 模型管理-保存（添加编辑）
export const ModelSave = (params) => { return req("post", "http://127.0.0.1:10001/modelInfo/saveOrUpdate", params) };
// 模型管理-删除模型
export const ModelDelete = (params) => { return req("post", "http://127.0.0.1:10001/modelInfo/delete", params) };
//上传模型文件接口--上传到python  选择python端口
export const modelUpload=(formData)=>{
    return axios(
        {
        method: "post",
        url: "http://127.0.0.1:5000/modelUpload",
        headers: {
            'Content-Type': 'multipart/form-data',
            'Access-Control-Allow-Origin': '*',
        },
        data: formData,
        traditional: true,
        }).then(res => res.data);};

// 上传数据集文件接口
export const FileUplod = (formData) => {
    return axios(
        {
        method: "post",
        url: "http://127.0.0.1:10001/modelDataInfo/upload",
        headers: {
            'Content-Type': 'multipart/form-data',
            'Access-Control-Allow-Origin': '*',
        },
        data: formData,
        traditional: true,
        }).then(res => res.data);};

// 上传数据集文件接口
export const fapiaoPicUplod = (formData) => {
  return axios(
    {
      method: "post",
      url: "http://192.168.2.88:9990/api/getocr/putfile",
      headers: {
        'Content-Type': 'multipart/form-data',
        token: localStorage.getItem('token'),
        'Access-Control-Allow-Origin': '*',
      },
      data: formData,
      traditional: true,
    }).then(res => res.data);};

// 数据集管理-获取模型列表
export const ModelDataList = (params) => { return req("get", "http://127.0.0.1:10001/modelDataInfo/list?pageNum="+params.pageNum+"&pageSize="+params.pageSize+"&dataName="+params.dataName)};
// 数据集管理-保存（添加编辑）
export const ModelDataSave = (params) => { return req("post", "http://127.0.0.1:10001/modelDataInfo/saveOrUpdate", params) };
// 数据集管理-删除数据集
export const ModelDataDelete = (params) => { return req("post", "http://127.0.0.1:10001/modelDataInfo/delete", params) };
// 数据集管理-数据集详情
export const ModelDataDetail = (param) => { return req("get", "http://127.0.0.1:10001/modelDataInfo/detail?id="+param)};
// 根据模型id查询数据集列表
export const ModelDataListByModelId = (param) => { return req("get", "http://127.0.0.1:10001/modelDataInfo/getByModelId?modelId="+param)};
/**
 * 算法配置管理
 **/
// 获取算法配置列表
export const configList = (params) => { return req("get", "http://127.0.0.1:10001/config/list?pageNum="+params.pageNum+"&pageSize="+params.pageSize+"&modelConfigName="+params.modelConfigName)};

// 新增算法配置
export const configSave = (params) => { return req("post", "http://127.0.0.1:10001/config/add", params) };

// 删除算法配置
export const configDelete = (params) => { return req("get","http://127.0.0.1:10001/config/delete?configId=" + params ) };

// 修改算法配置
export const configUpdate = (params) => { return req("post", "http://127.0.0.1:10001/config/update", params) };

// 执行算法配置
export const configAction = (params) => { return req("get", "http://127.0.0.1:10001/config/actionNow?configId="+params.id +"&epochs="+params.epochs+"&lr="+params.lr+"&batchSize="+params.batchSize+"&tagId="+params.tagId) };

// 查看执行详情
export const actionStatus = (params) => { return req("get", "http://127.0.0.1:10001/config/actionStatus?configId="+params) };

// 查看执行详情
export const detailList = (params) => { return req("get", "http://127.0.0.1:10001/config/actionDetail?configId="+params) };

// 停止某配置的模型训练
export const modelStop = (params) => { return req("get","http://127.0.0.1:10001/config/stopNow?configId=" + params ) };

/**
 * 菜单管理
 **/
// 菜单管理-获取菜单Module/list
export const ModuleList = () => { return req("post", "/api/Module/list") };
// 菜单管理-根据菜单获取数据
export const ModuleGet = (params) => { return axios.get("/api/Module/get/" + params + "?token=" + localStorage.getItem('logintoken')) };
// 菜单管理-获取父级菜单Module/nodes
export const ModuleNodes = (params) => { return req("post", "/api/Module/nodes", params) };
// 菜单管理-修改菜单
export const ModuleSave = (params) => { return req("post", "/api/Module/save", params) };
// 菜单管理-删除菜单
export const ModuleDelete = (params) => { return axios.delete("/api/Module/delete?ids=" + params + "&token=" + localStorage.getItem('logintoken')).then(res => res.data) };

/**
 * 角色管理
 **/
// 角色管理-获取角色列表
export const roleList = (params) => { return req("post", "/api/Role/list", params) };
// 角色管理-保存（添加编辑）
export const roleSave = (params) => { return req("post", "/api/Role/save", params) };
// 角色管理-删除角色
export const roleDelete = (params) => { return axios.delete("/api/Role/delete?ids=" + params + "&token=" + localStorage.getItem('logintoken')).then(res => res.data) };
// 角色管理-菜单权限（获取）
export const RoleRightTree = (params) => { return axios.get("/api/RoleRight/tree/" + params + "?token=" + localStorage.getItem('logintoken')) };
// 角色管理-菜单权限（保存）
export const RoleRightSave = (params) => { return req("post", "/api/RoleRight/save", params) };

/**
 * 公司管理
 **/
// 公司管理-获取公司列表
export const deptList = (params) => { return req("post", "/api/Dept/list", params) };
// 公司管理-保存（添加编辑）
export const deptSave = (params) => { return req("post", "/api/Dept/save", params) };
// 公司管理-删除公司
export const deptDelete = (params) => { return axios.get("/api/Dept/delete?ids=" + params + "&token=" + localStorage.getItem('logintoken')).then(res => res.data) };

/**
 * 系统环境变量
 **/
// 系统环境变量-获取系统环境变量列表
export const variableList = (params) => { return req("post", "/api/Variable/list", params) };
// 系统环境变量-保存（添加编辑）
export const variableSave = (params) => { return req("post", "/api/Variable/save", params) };
// 系统环境变量-删除系统环境变量
export const variableDelete = (params) => { return axios.delete("/api/Variable/delete?ids=" + params + "&token=" + localStorage.getItem('logintoken')).then(res => res.data) };

/**
 * 权限管理
 **/
// 权限管理-获取权限列表
export const permissionList = (params) => { return req("post", "/api/Permission/list", params) };
// 权限管理-保存权限
export const ermissionSave = (params) => { return req("post", "/api/Permission/save", params) };
// 权限管理-删除权限
export const ermissionDelete = (params) => { return axios.delete("/api/Permission/delete?ids=" + params + "&token=" + localStorage.getItem('logintoken')).then(res => res.data) };
// 权限管理-获取权限
export const roleDropDown = () => { return axios.get("/api/Role/dropDown/all?&token=" + localStorage.getItem('logintoken')).then(res => res.data) };
// 权限管理-配置权限
export const RolePermission = (params) => { return req("post", "/api/RolePermission/save", params) };
